package com.example.controller;

import com.example.entity.Information;
import com.example.ext.entity.ExtInformation;
import com.example.service.InformationService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

import java.util.Map;

/**
 * Created by simon on 2017/10/12.
 */
@RestController
@RequestMapping("api/information")
@EnableWebMvc
public class InformationController {

    @Autowired
    private InformationService informationService;

    @ApiOperation(value = "查询资讯列表的信息",notes = "获取资讯列表信息")
    @RequestMapping(value="/queryList",method = RequestMethod.POST)
    Map<String,Object> queryList(@RequestBody ExtInformation extInformation) {

        return informationService.queryList(extInformation);
    }

    @ApiOperation(value = "新增资讯信息",notes = "新增资讯信息")
    @RequestMapping(value="/add",method = RequestMethod.POST)

    Map<String,Object> add(@RequestBody ExtInformation extInformation) {

        return informationService.add(extInformation);
    }

    @ApiOperation(value = "修改资讯",notes = "修改资讯")
    @RequestMapping(value="/update",method = RequestMethod.POST)
    Map<String,Object> update(@RequestBody ExtInformation extInformation) {

        return informationService.update(extInformation);
    }

    @ApiOperation(value = "删除",notes = "删除")
    @RequestMapping(value="/deleteById/{id}",method = RequestMethod.POST)
    Map<String,Object> deleteById(@PathVariable(value = "id") String id) {

        return informationService.delete(id);
    }

    @RequestMapping(value="/queryById/{id}",method = RequestMethod.POST)
    Map<String,Object> queryById(@PathVariable(value = "id") String id) {

        return informationService.queryById(id);
    }
}
